package com.woniu.p2p.config;

import com.alibaba.druid.pool.DruidDataSource;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration  //相当于Spring的配置文件
//@EnableWebMvc   //全面接管自动配置
//@MapperScan(value = "com.woniu.mapper")
public class MyConfig implements WebMvcConfigurer {

    //扩展配置登录页面
    WebMvcConfigurer webMvcConfigurer = new WebMvcConfigurer() {
        @Override
        public void addViewControllers(ViewControllerRegistry registry) {
//            registry.addViewController("/").setViewName("login");
//            registry.addViewController("/login.html").setViewName("login");
//            registry.addViewController("/login").setViewName("login");
//            registry.addViewController("/borrow").setViewName("borrow");
        }
    };

    @Bean
    public WebMvcConfigurer webMvcConfigurer() {
        return webMvcConfigurer;
    }

    @Bean
    @ConfigurationProperties(value = "spring.datasource")
    public DruidDataSource druidDataSource(){
        return new DruidDataSource();
    }


}




